]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Make the search entry behave better in RTL locales
authorMatthias Clasen <mclasen@redhat.com>
Mon, 26 Aug 2013 22:24:26 +0000 (18:24 -0400)
committerFlorian Müllner <fmuellner@gnome.org>
Wed, 11 Sep 2013 16:41:55 +0000 (18:41 +0200)
It is expected that the primary and secondary icons in entries
change places in RTL locales. When doing so, the edit-clear
icon must be replaced by an rtl variant too.

http://bugzilla.gnome.org/show_bug.cgi?id=705779

js/ui/viewSelector.js
src/st/st-entry.c

index a78a9f72f97085e7f6a9f5be89714dd931200540..3cfa5cdbb8057e658371e513cccc081fcadfa015 100644 (file)
@@ -85,8 +85,12 @@ const ViewSelector = new Lang.Class({
 
         this._entry.set_primary_icon(new St.Icon({ style_class: 'search-entry-icon',
                                                    icon_name: 'edit-find-symbolic' }));
-        this._clearIcon = new St.Icon({ style_class: 'search-entry-icon',
-                                        icon_name: 'edit-clear-symbolic' });
+        if (this._entry.get_text_direction() == Clutter.TextDirection.RTL)
+            this._clearIcon = new St.Icon({ style_class: 'search-entry-icon',
+                                            icon_name: 'edit-clear-rtl-symbolic' });
+        else
+            this._clearIcon = new St.Icon({ style_class: 'search-entry-icon',
+                                            icon_name: 'edit-clear-symbolic' });
 
         this._iconClickedId = 0;
         this._capturedEventId = 0;
index 6aa4dc3311c467b9bf6dd67b664b9c77c2655e08..ed5f303d2c71270b0941acd6c64b7157c12b6565 100644 (file)
@@ -416,6 +416,18 @@ st_entry_allocate (ClutterActor          *actor,
   ClutterActorBox content_box, child_box, icon_box;
   gfloat icon_w, icon_h;
   gfloat entry_h, min_h, pref_h, avail_h;
+  ClutterActor *left_icon, *right_icon;
+
+  if (clutter_actor_get_text_direction (actor) == CLUTTER_TEXT_DIRECTION_RTL)
+    {
+      right_icon = priv->primary_icon;
+      left_icon = priv->secondary_icon;
+    }
+  else
+    {
+      left_icon = priv->primary_icon;
+      right_icon = priv->secondary_icon;
+    }
 
   clutter_actor_set_allocation (actor, box, flags);
 
@@ -426,12 +438,10 @@ st_entry_allocate (ClutterActor          *actor,
   child_box.x1 = content_box.x1;
   child_box.x2 = content_box.x2;
 
-  if (priv->primary_icon)
+  if (left_icon)
     {
-      clutter_actor_get_preferred_width (priv->primary_icon,
-                                         -1, NULL, &icon_w);
-      clutter_actor_get_preferred_height (priv->primary_icon,
-                                          -1, NULL, &icon_h);
+      clutter_actor_get_preferred_width (left_icon, -1, NULL, &icon_w);
+      clutter_actor_get_preferred_height (left_icon, -1, NULL, &icon_h);
 
       icon_box.x1 = content_box.x1;
       icon_box.x2 = icon_box.x1 + icon_w;
@@ -439,20 +449,16 @@ st_entry_allocate (ClutterActor          *actor,
       icon_box.y1 = (int) (content_box.y1 + avail_h / 2 - icon_h / 2);
       icon_box.y2 = icon_box.y1 + icon_h;
 
-      clutter_actor_allocate (priv->primary_icon,
-                              &icon_box,
-                              flags);
+      clutter_actor_allocate (left_icon, &icon_box, flags);
 
       /* reduce the size for the entry */
       child_box.x1 += icon_w + priv->spacing;
     }
 
-  if (priv->secondary_icon)
+  if (right_icon)
     {
-      clutter_actor_get_preferred_width (priv->secondary_icon,
-                                         -1, NULL, &icon_w);
-      clutter_actor_get_preferred_height (priv->secondary_icon,
-                                          -1, NULL, &icon_h);
+      clutter_actor_get_preferred_width (right_icon, -1, NULL, &icon_w);
+      clutter_actor_get_preferred_height (right_icon, -1, NULL, &icon_h);
 
       icon_box.x2 = content_box.x2;
       icon_box.x1 = icon_box.x2 - icon_w;
@@ -460,9 +466,7 @@ st_entry_allocate (ClutterActor          *actor,
       icon_box.y1 = (int) (content_box.y1 + avail_h / 2 - icon_h / 2);
       icon_box.y2 = icon_box.y1 + icon_h;
 
-      clutter_actor_allocate (priv->secondary_icon,
-                              &icon_box,
-                              flags);
+      clutter_actor_allocate (right_icon, &icon_box, flags);
 
       /* reduce the size for the entry */
       child_box.x2 -= icon_w - priv->spacing;